package com.ssd.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssd.entity.PartnerEntity;
import com.ssd.entity.vo.PartnerVo;
import com.ssd.mapper.PartnerDao;
import com.ssd.service.PartnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class PartnerServiceImpl extends ServiceImpl<PartnerDao, PartnerEntity> implements PartnerService {

    @Autowired
    private PartnerDao partnerDao;

    /**
     * 分页查询商品列表，支持模糊查询
     *
     * @param pageNum  当前页码
     * @param pageSize 每页大小
     * @return 分页的商品集合
     */
    @Override
    public Page<PartnerVo> getPartnerList(int pageNum, int pageSize,String partnerName) {
        Page<Map<String, Object>> page = new Page<>(pageNum, pageSize);
        return partnerDao.selectPartnerList(page,partnerName);
    }

    @Override
    public PartnerVo selectPartnerByPartnerId(Long partnerId) {
        return partnerDao.selectPartnerById(partnerId);
    }

    @Override
    public int insertPartner(PartnerEntity partner) {
        return partnerDao.insert(partner);
    }

    @Override
    public int updatePartner(PartnerEntity partner) {
        return partnerDao.updateById(partner);
    }

    @Override
    public int deletePartnerByPartnerIds(Long[] partnerIds) {
        return partnerDao.deleteBatchIds(java.util.Arrays.asList(partnerIds));
    }
}